<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AdminLog extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('admin_log')
            ->setComment('管理员日志表')
            ->addColumn(Column::integer('admin_id', 10)->setDefault(0)->setComment("管理人员id"))
            ->addColumn(Column::string('url',255)->setDefault('')->setComment("请求路径"))
            ->addColumn(Column::string('explain',255)->setDefault('')->setComment("操作说明"))
            ->addColumn(Column::text('content')->setComment("日志内容"))
            ->addColumn(Column::string('useragent', 255)->setDefault(''))
            ->addColumn(Column::dateTime('create_time')->setDefault(null))
            ->addColumn(Column::dateTime('update_time')->setDefault(null))
            ->addColumn(Column::string('ip',30)->setDefault('0'))
            ->addColumn(Column::string('method', 30)->setDefault(''))
            ->addIndex('admin_id')
            ->create();
    }
}
